abstract class Shape {
  //实现让子类实现
  //getArea方法只有声明，没有实现体
  //实现让子类自己实现
  //可以将getArea方法定义为抽象方法:在方法的前面加上abstract
  //抽象方法必须出现在抽象类中，类前面也需要加上abstact
  abstract getArea();
}

class Rectangle extends Shape {
  constructor(public width: number, public height: number) {
    super();
  }
  getArea() {
    return this.width * this.height;
  }
}

class Circle extends Shape {
  constructor(public radius: number) {
    super();
  }
  getArea() {
    this.radius ** 2 * Math.PI;
  }
}

class Triangle extends Shape {
  getArea() {
    return 100;
  }
}

//获取面积
function calcArea(shape: Shape) {
  return 100;
}

calcArea(new Rectangle(10, 22));

calcArea(new Circle(5));

calcArea(new Triangle());
//抽象类不能被实例化
